package com.ulife.permission.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ulife.permission.dao.TargetDao;
import com.ulife.permission.dao.dataobject.TargetDO;

public class TargetDaoImpl extends SqlMapClientDaoSupport implements TargetDao {

	public TargetDO getTargetById(long id) throws SQLException {
		return (TargetDO)getSqlMapClient().queryForObject("Target.getTargetById",id);
	}

	public TargetDO getTargetByTargetId(String targetId) throws SQLException {
		return (TargetDO)getSqlMapClient().queryForObject("Target.getTargetByTargetId",targetId);
	}

	public int addTarget(TargetDO target) throws SQLException {
		return getSqlMapClient().update("Target.insertTarget",target);
	}

	@SuppressWarnings("unchecked")
	public List<TargetDO> getAllTarget() throws SQLException {
		return getSqlMapClient().queryForList("Target.selectAllTargets");
	}

	public int updateTarget(TargetDO target) throws SQLException {
		return getSqlMapClient().update("Target.updateTarget", target);
	}

}
